package com.wswy.wyjk.utils

import android.annotation.SuppressLint
import com.raft.framework.utils.RxUtils
import com.wswy.wyjk.core.location.LocManager
import com.wswy.wyjk.model.LocalConfig

class CityUtils {

    @SuppressLint("CheckResult")
    fun allCity(city: String, currentLocalConfig: LocalConfig) {
        LocManager.getInstance().getCityInfo(city).compose(RxUtils.io2main()).subscribe { t1, t2 ->
            t1?.orNull()?.let {
                var code = it.adCode?.toIntOrNull() ?: 0
                currentLocalConfig.areaCode = code
                currentLocalConfig.cityName = city
            } ?: kotlin.run {
                t2?.printStackTrace()
            }
        }
    }
}